//
//  TabbarVC.m
//  YUXiu
//
//  Created by 王竞成 on 16/6/22.
//  Copyright © 2016年 Wang. All rights reserved.
//

#import "TabbarVC.h"
#import "OL_ViewController.h"
#import "Course_ViewController.h"
#import "Store_ViewController.h"
#import "MY_ViewController.h"

#import "BaseNaviViewController.h"

@interface TabbarVC ()
@property (nonatomic,weak) OL_ViewController *onlineVC;

@property (nonatomic,weak) Course_ViewController *courseVC;

@property (nonatomic,weak) Store_ViewController *storeVC;

@property (nonatomic,weak) MY_ViewController *myVC;

@end

@implementation TabbarVC

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view from its nib.
    [self addAllChildVC];
    
}

//添加子控制器
-(void)addAllChildVC{
//    直播，课程，商城，个人
    OL_ViewController *onlineVC = [[OL_ViewController alloc] init];
    [self addChildVC:onlineVC title:@"直播" imageName:@"navigationbar_Personal_normal" selectedImageName:@"navigationbar_Personal_normal"];
    self.onlineVC = onlineVC;

    Course_ViewController *courseVC = [[Course_ViewController alloc] init];
    [self addChildVC:courseVC title:@"课程" imageName:@"navigationbar_Personal_normal" selectedImageName:@"navigationbar_Personal_normal"];
    self.courseVC = courseVC;

    Store_ViewController *storeVC = [[Store_ViewController alloc] init];
    [self addChildVC:storeVC title:@"商城" imageName:@"未标题-4_06" selectedImageName:@"未标题-4_06"];
    self.storeVC = storeVC;

     MY_ViewController *myVC = [[MY_ViewController alloc] init];
    [self addChildVC:myVC title:@"个人" imageName:@"navigationbar_Personal_normal" selectedImageName:@"navigationbar_Personal_normal"];
    self.myVC = myVC;
    UILabel * la = [[UILabel alloc]init];
}

/** 添加一个子控制器 */
- (void)addChildVC:(UIViewController *)childVC title:(NSString *)title imageName:(NSString *)imageName selectedImageName:(NSString *)selectedImageName
{
    childVC.title = title;
    childVC.tabBarItem.image = [[UIImage imageNamed:imageName] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
    childVC.tabBarItem.selectedImage = [[UIImage imageNamed:selectedImageName] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
    // 设置tabbar普通状态下的文字样式
    NSDictionary *textAttrs = @{NSForegroundColorAttributeName : [UIColor colorWithHexString:@"#999999"],
                                NSFontAttributeName : [UIFont boldSystemFontOfSize:14]};
    [childVC.tabBarItem setTitleTextAttributes:textAttrs forState:UIControlStateNormal];
    
    // 设置tabbar高亮状态下的文字样式
    UIFont *font = [UIFont systemFontOfSize:14];
    NSDictionary *selectedTextAttrs = @{NSForegroundColorAttributeName : kNaviThemColor,NSFontAttributeName : font};
    [childVC.tabBarItem setTitleTextAttributes:selectedTextAttrs forState:UIControlStateSelected];
    
    BaseNaviViewController *nav = [[BaseNaviViewController alloc] initWithRootViewController:childVC];
    [self addChildViewController:nav];

    
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
